package com.chen.baozhangmonitor;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;



import java.util.List;

public class RecycleAdapter extends RecyclerView.Adapter<RecycleAdapter.MyViewHolder> {

    private List<String> name;
    private List<String> shangbang;
    private List<String> baozhang;
//    private List<Bitmap> headImg;


    public void setData(List<String> name , List<String> shangbang , List<String> baozhang ){
        this.name = name;
        this.shangbang = shangbang;
        this.baozhang = baozhang;
//        this.headImg = headImg;
        notifyDataSetChanged();
    }
    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.line_chart_item,viewGroup,false);
        MyViewHolder vh = new MyViewHolder(v);
        return vh;
    }

    @Override
    public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, int i) {
        myViewHolder.mName.setText(name.get(i));
        myViewHolder.mAmount.setText("总上榜:"+shangbang.get(i)+"次");
        myViewHolder.mBaozhang.setText("暴涨倍数"+baozhang.get(i));
//        myViewHolder.mHead.setImageBitmap(headImg.get(i));

    }


    @Override
    public int getItemCount() {
        return name == null? 0:name.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        public ImageView mHead;
        public TextView mName;
        public TextView mAmount;
        public TextView mBaozhang;
        public Button mIntent;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            mHead = itemView.findViewById(R.id.item_head);
            mName = itemView.findViewById(R.id.item_name);
            mAmount = itemView.findViewById(R.id.item_amount);
            mBaozhang = itemView.findViewById(R.id.item_baozhang);
            mIntent = itemView.findViewById(R.id.item_intent);
        }
    }
}
